package com.t235.gc.order.controller;

import com.t235.gc.order.service.SysManagerService;
import com.t235.gc.order.service.VenuesService;
import com.t235.gc.vo.RecyclingOrderVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.t235.gc.AjaxResult;
import com.t235.gc.entity.GarbageRecyclingOrder;
import com.t235.gc.entity.SysManager;
import com.t235.gc.order.service.PartnersService;
import com.t235.gc.order.service.RecyclingOrderService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api
@RestController
@RequestMapping("/api/garbage-recycling-order")
public class GarbageRecyclingOrderController {
    @Value(value = "${server.port}")
    private String port;
    @Autowired
    private RecyclingOrderService recyclingOrderService;
    @Autowired
    private PartnersService partnersService;
    @Autowired
    private VenuesService venuesService;
    @Autowired
    private SysManagerService sysManagerService;

    /**
     * 垃圾投放订单列表
     * @param vo
     * @param page
     * @param pageSize
     * @return
     */
    @PostMapping("/admin/getGarbageRecyclingOrderList")
    @ApiOperation(value = "查询垃圾投递订单", httpMethod = "POST")
    public AjaxResult getGarbageRecyclingOrderList(RecyclingOrderVo vo, @RequestParam(value = "page") Integer page, @RequestParam(value = "limit") Integer pageSize) {
        PageHelper.startPage(page, pageSize);
        List<GarbageRecyclingOrder> list = recyclingOrderService.getList(vo);
        PageInfo<GarbageRecyclingOrder> pageInfo = new PageInfo<>(list);
        return AjaxResult.success(pageInfo);
    }

    @GetMapping("/admin/getBackVenuesList")
    @ApiOperation(value = "查询设备场地列表")
    public Object getBackVenuesList() {
        return venuesService.getList();
    }

    @GetMapping("/admin/getPartnersList")
    @ApiOperation(value = "查询合伙人列表")
    public Object getPartnersList() {
        return partnersService.getList();
    }

    @GetMapping("/admin/getSortingOrOperatorsList")
    @ApiOperation(value = "查询运营商，分拣中心列表")
    public List<SysManager> getSortingOrOperatorsList(Integer managerType) {
        List<SysManager> list = sysManagerService.getList(managerType);
        return list;
    }
}
